home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / libraris / reqlib12 / part03 < prev   
Encoding:
Internet Message Format  |  1990-09-28  |  62.7 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i261: requester.library 1.2 - requester library, Part03/03
  4. Reply-To: Paul-Erik Raue <peraue@cs.vu.nl>
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i261@abcfd20.larc.nasa.gov>
  7. References: <comp.sources.amiga:v90i259@abcfd20.larc.nasa.gov>
  8. Date: 28 Sep 90 18:45:55 GMT
  9. Approved: tadguy@uunet.UU.NET (Tad Guy)
  10. X-Mail-Submissions-To: amiga@uunet.uu.net
  11. X-Post-Discussions-To: comp.sys.amiga
  12.  
  13. Submitted-by: Paul-Erik Raue <peraue@cs.vu.nl>
  14. Posting-number: Volume 90, Issue 261
  15. Archive-name: libraries/reqlib-1.2/part03
  16.  
  17. #!/bin/sh
  18. # This is a shell archive.  Remove anything before this line, then unpack
  19. # it by saving it into a file and typing "sh file".  To overwrite existing
  20. # files, type "sh file -c".  You can also feed this as standard input via
  21. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  22. # will see the following message at the end:
  23. #        "End of archive 3 (of 3)."
  24. # Contents:  req.doc
  25. # Wrapped by tadguy@abcfd20 on Fri Sep 28 14:45:31 1990
  26. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  27. if test -f 'req.doc' -a "${1}" != "-c" ; then 
  28.   echo shar: Will not clobber existing file \"'req.doc'\"
  29. else
  30. echo shar: Extracting \"'req.doc'\" \(60498 characters\)
  31. sed "s/^X//" >'req.doc' <<'END_OF_FILE'
  32. X
  33. X    The  req.library is a run time re-entrant library that is designed
  34. Xto  make  it  easier  for  programmers  to  use  powerful, easy to use
  35. Xrequesters  for  communicating  with  users.   The  requester  library
  36. Xincludes  such functions as a color requester, file requester, message
  37. Xdisplay  requester  and many functions to make the creation of gadgets
  38. Xfor your own custom requesters easier.
  39. X
  40. X    Req.library  was  written  by  Colin  Fox (of Pyramyd Designs) and
  41. XBruce  Dawson  (of  CygnusSoft  Software).   Req.library  is  a freely
  42. Xdistributable  library that may be used in commercial products without
  43. Xpaying  any  royalties.  We encourage you to use the requester library
  44. Xin all of your programs, to make them easier to write, and to use.
  45. X
  46. X    Req.library  is  not public domain.  The requester library and all
  47. Xdocumentation and example programs are all copyright 1989.
  48. X
  49. X    The  requester  library must be distributed with the documentation
  50. Xfile  (req.doc),  and  the  three  include files (req.h, reqbase.h and
  51. Xreqbase.i).
  52. X
  53. X
  54. X
  55. X    Req.library  is  dedicated  to  the programmers who make the Amiga
  56. Xshine the way it was meant to.
  57. X
  58. X
  59. XOverView:
  60. X
  61. X    All  of  the  req.library functions that bring up requesters allow
  62. Xyou two ways of specifying what screen you would like the requester to
  63. Xappear  on.  The first way is the more efficient way, because you only
  64. Xhave  to set it up once and then it takes care of things automatially.
  65. XThere  is  a  field in all process structures called the pr_WindowPtr.
  66. XThis  pointer  is  used by DOS to decide where to put it's requesters.
  67. XIf  pr_WindowPtr  contains  a  zero,  requesters  go  on the workbench
  68. Xscreen.  If it contains the address of a window, then requesters go on
  69. Xthat  window's  screen.   If  it  contains a negative one, then no DOS
  70. Xrequesters come up.  The req.library requesters all use this variable,
  71. Xif  they  are  called from a process .  However, if the pointer is -1,
  72. Xthe req.library functions do still appear, on the workbench screen.
  73. X
  74. X    The  second  way  was  put in mainly so that the requesters can be
  75. Xcalled from tasks.  Since a task does not have a process structure, it
  76. Xalso  lacks a pr_WindowPtr.  Therefore, all of the requester functions
  77. Xwhich  can  be  used from a task (currently everything except the file
  78. Xrequester) can be passed a window pointer, either as a parameter or as
  79. Xan  element in a structure.  Important:  This pointer takes precedence
  80. Xover  the  pr_WindowPtr  so  if  you  wish  the  requesters to use the
  81. Xpr_WindowPtr  you  must  zero  the window fields that the routines are
  82. Xexpecting.   In  the case of fields in a structure this can be easy as
  83. Xlong   as  you  make  sure  your  structure  defaults  to  being  zero
  84. Xeverywhere.
  85. X
  86. X    Setting  the  pr_WindowPtr is quite a simple matter.  All you have
  87. Xto do is do a FindTask((char *)0); which returns a pointer to your own
  88. Xtask  and your own process (a task structure is the first element of a
  89. Xprocess  structure).   Then  you  simply  preserve  the  old  value of
  90. Xpr_WindowPtr (VERY IMPORTANT!!!) and put a window pointer into it.
  91. X
  92. Xeg:
  93. X                /* Find my task. */
  94. X    myprocess = (struct Process *)FindTask((char *)0);
  95. X    oldwindowptr = myprocess->pr_WindowPtr;
  96. X    myprocess->pr_WindowPtr = window;
  97. X
  98. Xor:
  99. X
  100. X    MOVE.L  4,A6
  101. X    MOVE.L  #0,A1
  102. X    SYS     FindTask    ;Find my task.
  103. X    MOVE.L  D0,_myprocess
  104. X    MOVE.L  D0,A0
  105. X    MOVE.L  pr_WindowPtr(A0),_oldwindowptr
  106. X    MOVE.L  _window,pr_WindowPtr(A0)
  107. X
  108. X    Before your program exits it is VERY important that it restore the
  109. Xprevious  value of pr_WindowPtr.  If you don't, then your program will
  110. Xwork  in some situations, but will BLOW UP in others.  For example, if
  111. Xyou  execute  (without  using the 'run' command) a program, which then
  112. Xsets  the  pr_WindowPtr  to  point at one of its windows and the exits
  113. Xwithout  restoring  it,  then  the  next time a DOS requester tries to
  114. Xappear...  BOOM!  The machine will probably crash as DOS tries to open
  115. Xa requester on a now closed screen.  Therefore, before leaving:
  116. X
  117. X    myprocess->pr_WindowPtr = oldwindowptr;
  118. X
  119. Xor:
  120. X
  121. X    MOVE.L  _myprocess,A0
  122. X    MOVE.L  _oldwindowptr,pr_WindowPtr(A0)
  123. X
  124. X
  125. X
  126. X    One  final  note.   The  pr_WindowPtr  field exists in the process
  127. Xstructure.   This  means  that  a  task  does  not  have  this  field.
  128. XTherefore,  if you want to call one of the requester library functions
  129. Xfrom  a  task,  you  will not be able to specify what screen you would
  130. Xlike  the  requester  to  appear on by setting the pr_WindowPtr field.
  131. XAll  of  the  functions  that open requesters and can be called from a
  132. Xtask  (the file requester/font requester is the only one that can't be
  133. Xcalled  froma task) have some other way of specifying which screen you
  134. Xwould like them to open on.  They will have either have a field in the
  135. Xstructure  which you must pass them or a parameter which can contain a
  136. Xwindow  pointer  to one of the windows on your custom screen.  If this
  137. Xpointer is non-zero then it overrides the pr_WindowPtr field.
  138. X
  139. X
  140. X
  141. X
  142. X    By  opening the requester library, you not only gain access to all
  143. Xof  the functions documented below, but to some other goodies as well.
  144. XReq.library   needs  and  therefore  opens  several  other  libraries,
  145. Xincluding  dos.library,  intuition.library,  graphics.library  and the
  146. Xconsole  device.   All  of  these  pointers  are  stored in the ReqLib
  147. Xstructure  which  you  get a pointer to when you open the req.library.
  148. XTherefore,  you  can  save  yourself  a little bit of code by grabbing
  149. Xthese  fields  after opening the requester library.  The only thing to
  150. Xbeware of is don't use these values after you have close the requester
  151. Xlibrary,  because  at  that point there is no guarantee that they will
  152. Xstill be valid.
  153. X
  154. X    In  addition  to  these  libraries,  the Images pointer in the req
  155. Xlibrary structure points to a set of ten small images (four arrows and
  156. Xssix  letters)  which have are guaranteed to be in chip memory.  These
  157. Xcan be used if your program requires this type of images.
  158. X
  159. X
  160. X
  161. X
  162. X    One  thing to keep in mind when using the gadget creation routines
  163. Xis  that there isn't any way for us to check that you have passed us a
  164. Xpointer  to  the  correct size of buffer, so you _must_ make sure that
  165. Xyou are allocating the right amount of memory.
  166. X
  167. X
  168. X--------------------------------------------------------------
  169. XHere's a quick list of the functions available:
  170. X--------------------------------------------------------------
  171. X
  172. XCenter..................Center a new window over the mouse.
  173. X
  174. XSetSize.................Prop gadget handling routines (32 bit)
  175. XSetLocation
  176. XReadLocation
  177. X
  178. XFormat..................sprintf() format routine
  179. X
  180. XSimpleRequest...........Starter gluecode to TextRequest- Single gadget
  181. XTwoGadRequest...........Starter gluecode to TextRequest- Two gadgets
  182. X
  183. XFileRequester...........FileRequester routines
  184. XPurgeFiles
  185. X
  186. XColorRequester..........a colorrequester
  187. X
  188. XMakeGadget..............Gadget creation routines
  189. XMakeString
  190. XMakeProp
  191. XMakeButton
  192. X
  193. XMakeScrollBar...........3   part   gadget;   2   arrows  and  a  prop.
  194. X                        Horizontal or Vertical
  195. X
  196. XLinkGadget..............Gadget  creation  routines that self-hook into
  197. X                        the newwindow
  198. XLinkStringGadget........gadget list.
  199. XLinkPropGadget
  200. X
  201. XDrawBox.................Draw a box (x1y1)(x2y2) in one command
  202. X
  203. XGetFontHeightAndWidth...return height and width of current font
  204. X
  205. XRealTimeScroll..........scroll routine used in file requester
  206. X
  207. XTextRequest.............Powerful requester function
  208. X
  209. XGetString...............Get a line of text from the user
  210. XGetLong.................Get a signed long from the user
  211. X
  212. XRawKeyToAscii...........Convert raw key to ascii
  213. X
  214. X----------------------------------------------------------------
  215. X
  216. X
  217. XNAME
  218. X        Center
  219. X
  220. X
  221. XSYNOPSIS
  222. X        Center( &nw, x, y)
  223. X                 A0 D0 D1
  224. X
  225. Xstruct NewWindow *nw;
  226. XUSHORT x,y;
  227. X
  228. XDESCRIPTION
  229. X
  230. X    Center()  is  used  to  adjust  a  NewWindow structure so that the
  231. Xwindow that it opens will appear immediately under the mouse.  The x,y
  232. Xvalues  are used to specify which part of the window you would like to
  233. Xappear  underneath  the mouse.  If x or y is zero, that tells Center()
  234. Xto  position  the  window  so  that  the  window center (in the x or y
  235. Xdirection  respectively)  is  underneath  the  mouse.   If  x  or y is
  236. Xpositive, that tells Center() to position the window so that the mouse
  237. Xis  that  many  pixels  from  the  left  or  top  edge  of  the window
  238. Xrespectively.   If x or y is negative, that tells Center() to position
  239. Xthe  window  structure so that the mouse appears that many pixels from
  240. Xthe right or bottom edge of the window respectively (ie; x = -10 tells
  241. XCenter  to  position  the  mouse  ten  pixels to the left of the right
  242. Xedge).
  243. X
  244. X    If it is impossible to position the window exactly where requested
  245. X(if  the  mouse  pointer  is too close to the edge of the screen) then
  246. Xthis  routine  will  position  the  window as close as possible to the
  247. Xcorrect location.
  248. X
  249. X    To  allow  this routine to work accurately it is necessary to have
  250. Xalready initialized the new window structure to specify on what screen
  251. Xthe  window  is  going  to  be  open.  ie; you should set the Type and
  252. XScreen fields before calling Center().
  253. X
  254. X    This routine disturbs no registers.
  255. X
  256. XRETURNS
  257. X        nothing
  258. XSEE
  259. X
  260. XBUGS
  261. X        None known
  262. X
  263. X
  264. X;--------------------------------------------------------------------
  265. X
  266. XNAME
  267. X            SetSize
  268. XSYNOPSIS
  269. X
  270. X            SizeVal=SetSize(MaxValue,ViewSize)
  271. X              D0.W              D0.L  D1.L
  272. X
  273. Xshort   SizeVal;
  274. Xlong    MaxValue,ViewSize;
  275. X
  276. XDESCRIPTION
  277. X
  278. X    This  routine is designed to correctly handle sizing a prop gadget
  279. Xto  a range.  The range is given in in MaxValue/ViewSize.  MaxValue is
  280. Xthe  maximum value that this prop is supposed to be able to represent.
  281. XViewsize  is  how  large  the  display area is.  For instance, if your
  282. Xmaximum  value  was 200 (files, for example), and your viewsize was 15
  283. X(lines of text), then you would call this as so:
  284. X
  285. X        SizeVal=SetSize(200,15);
  286. X
  287. X    Then you would put SizeVal into the appropriate PropInfo structure
  288. Xelement (in the case of the file requester, that would be VertBody).
  289. X
  290. XRETURNS
  291. X        The  16 bit value to be put into the PropInfo structure of the
  292. Xprop gadget.
  293. X
  294. XSEE
  295. X        SetLocation, ReadLocation
  296. XBUGS
  297. X        Bugs? what bugs?
  298. X
  299. X
  300. X;--------------------------------------------------------------------
  301. X
  302. XNAME
  303. X            SetLocation
  304. XSYNOPSIS
  305. X
  306. XNewLoc = SetLocation(MaxValue,ViewSize,Value);
  307. X  D0                    D0      D1      D2
  308. X
  309. Xshort NewLoc;
  310. Xlong MaxValue,ViewSize,Value;
  311. X
  312. XDESCRIPTION
  313. X
  314. X            When you have a prop gadget that you wish to directly set,
  315. Xthen  this  is  the  routine to use.  It allows you to pass any 32 bit
  316. Xvalue and properly set the gadget.
  317. X
  318. XRETURNS
  319. X
  320. X    The  return  is  the value to put into either HorizPot or VertPot,
  321. Xdepending on what orientation you have the gadget.
  322. X
  323. X
  324. XBUGS
  325. X
  326. X    n/a
  327. X
  328. XEXAMPLE
  329. X
  330. XSEE
  331. X    SetSize(),ReadLocation()
  332. X
  333. X;--------------------------------------------------------------------
  334. X
  335. XNAME
  336. X            ReadLocation
  337. XSYNOPSIS
  338. X
  339. XLocVal=ReadLocation(MaxValue,ViewSize,PotValue)
  340. X  D0                  D0.L    D1.L     D2.W
  341. X
  342. Xlong LocVal,MaxVal,ViewSize;
  343. Xshort PotValue;
  344. X
  345. X
  346. XDESCRIPTION
  347. X
  348. X        If  you  prop  gadget has been moved, this is the routine that
  349. Xyou would use to determine where it's been moved to.
  350. X
  351. XRETURNS
  352. X        Returns  the decoded value of the prop, as an unsigned 32 bit.
  353. XThis  is  the  element  number  (line  number  usually) that should be
  354. Xdisplayed on the first line of your display window.
  355. X
  356. XSEE
  357. X
  358. X    SetSize(), SetLocation()
  359. X
  360. XBUGS
  361. X    n/a
  362. X
  363. XEXAMPLE
  364. X
  365. X;--------------------------------------------------------------------
  366. X
  367. XNAME
  368. X            Format
  369. XSYNOPSIS
  370. X
  371. X        Format(Buffer,string,values)
  372. X                A2      A0     A1
  373. X
  374. Xchar *Buffer,string[];
  375. Xchar **values;
  376. X
  377. XDESCRIPTION
  378. X
  379. X        This does the same thing as sprintf(), except that it isn't in
  380. Xthe  stdio  library, and doesn't use up very much room.  This function
  381. Xuses  the  ROM  function  RawDoFmt to do the print() style formatting.
  382. XThis  routine does not allow the use of all of the '%' directives (for
  383. Xexample,  floating  point  numbers can not be printed with this).  For
  384. Xfull   documentation   on  what  directives  are  supported,  see  the
  385. Xdocumentation  on RawDoFmt.  This is the routine that TextRequest (and
  386. Xtherefore   SimpleRequest   and  TwoGadRequest)  use  for  their  text
  387. Xformatting, so these restrictions apply to them also.
  388. X
  389. X        The RawDoFmt routine also assumes that 'int's are sixteen bits
  390. Xlong.   Therefore,  if  you  are  using a compiler with an int size of
  391. Xthirty-two  bits and you want to print an int or a short, you must use
  392. X'%ld', rather than '%d'.
  393. X
  394. XRETURNS
  395. X        The number of characters in the formatted string.
  396. XBUGS
  397. X    none known
  398. X
  399. XEXAMPLE
  400. X
  401. X    Format(Buffer,"There are %d changes to the file %s.",numchanges,
  402. Xfilename);
  403. X
  404. X    Format(Buffer,"%x is a hex number, %c is a character.", num, chr);
  405. X
  406. XSEE
  407. X    TextRequest, SimpleRequest, TwoGadRequest.
  408. X    Further  information  on printf() style formatting is available in
  409. Xthe AutoDocs on RawDoFmt and in C manuals discussing printf().
  410. X
  411. X;--------------------------------------------------------------------
  412. X
  413. X
  414. X
  415. XNAME
  416. X            ColorRequester
  417. XSYNOPSIS
  418. X
  419. XNewColor=ColorRequester(DesiredColor);
  420. X   D0                       D0
  421. Xlong    DesiredColor;
  422. X
  423. XDESCRIPTION
  424. X
  425. X    This  is a full-fledged color requester.  It is intelligent enough
  426. Xto open with the right number of colours in the palette automatically.
  427. XIt  shows  you both the colour you are working with, and the numerical
  428. XRGB  value  of  that  colour.   It  has  Spread,  Undo,  Ok and Cancel
  429. Xfunctions.  Planned is the addition of HSV.
  430. X
  431. X    The  cursor  keys move the color-cursor around the palette, RETURN
  432. Xselects the current color and ESC cancels out.
  433. X
  434. X    You  pass  this  routine  the  color that you would like initially
  435. Xhighlighted  (typically  the  current drawing colour).
  436. X
  437. X    The ExtendedColorRequester function has slightly more options, but
  438. Xis slightly more work to call.
  439. X
  440. XRETURNS
  441. X
  442. X    Color  number  that  the user selected, -1 if the user cancels the
  443. Xcolour  requester.   The  changed  colours  will  be  in  the viewport
  444. Xstructure for your screen.
  445. X
  446. XSEE
  447. X    ExtendedColorRequester
  448. X
  449. XBUGS
  450. X
  451. X    none known.
  452. X
  453. XEXAMPLE
  454. X
  455. X    newcolor = ColorRequester(oldcolor);
  456. X
  457. X;--------------------------------------------------------------------
  458. X
  459. XNAME
  460. X            ExtendedColorRequester
  461. XSYNOPSIS
  462. X
  463. XNewColor=ExtendedColorRequester(&(struct ExtendedColorRequester)
  464. X   D0                                      A0
  465. Xstruct ExtendedColorRequester   colorreqstruct;
  466. X
  467. XDESCRIPTION
  468. X    This  call  brings  up  exactly  the  same  color requester as the
  469. XColorRequester  call.  The only difference is that this routine allows
  470. Xyou  to  specify  more  parameters.   The difference is actually quite
  471. Xsmall  right  now, because there is only one additional parameter that
  472. Xcan  be  passed  through  this  entry  point.   This is the ecr_window
  473. Xparameter,  used  to  specify  what window (and hence what screen) the
  474. Xcolor 'requester' appears on.  This parameter is rarely needed because
  475. Xthe  window  the requester opens up on can be specified by setting the
  476. Xpr_WindowPtr  field  in  your process structure to the address of your
  477. Xwindow  structure  (see  the  beginning of the docs for an overview on
  478. Xthis procedure).  The only time this entry point is needed, currently,
  479. Xis  if you try to bring up the color requester on a custom screen from
  480. Xa  task,  since  a task does not have a pr_WindowPtr and can therefore
  481. Xnot specify the window and screen.
  482. X
  483. XRETURNS
  484. X
  485. X    Color  number  that  the user selected, -1 if the user cancels the
  486. Xcolour  requester.   The  changed  colours  will  be  in  the viewport
  487. Xstructure for your screen.
  488. X
  489. XSEE
  490. X    ColorRequester
  491. X
  492. XBUGS
  493. X
  494. X    none known.
  495. X
  496. XEXAMPLE
  497. X
  498. X        /* This should generally be declared as a global variable */
  499. X        /* so that all of it's elements get initialized to zero.  */
  500. X        /* If you declare it as a local variable, be sure to zero */
  501. X        /* all of the fields, even the unused ones. */
  502. X    struct ExtendedColorRequester   colorstruct;
  503. X
  504. X    colorstruct.defcolor = 0;
  505. X    colorstruct.window = mywindow;
  506. X    newcolor = ExtendedColorRequester(&colorstruct);
  507. X
  508. X;--------------------------------------------------------------------
  509. X
  510. XNAME
  511. X            MakeGadget
  512. XSYNOPSIS
  513. XMakeGadget(Buffer,String, X, Y)
  514. X              A0    A1   D0 D1
  515. Xstruct Buffer   *GadgetBlock;
  516. Xchar            *String;
  517. Xlong            D0,D1;
  518. XDESCRIPTION
  519. X
  520. X        This  routine  prepares a buffer to be a standard BOOLEAN text
  521. Xgadget.   This is a simple way of producing gadgets for code that must
  522. Xbe  reentrant,  and it is more efficient than defining gadgets in data
  523. Xstatements.    The  routine  initializes  the  gadgets  to  a  set  of
  524. X'standard' values that should cover most cases and then links the four
  525. Xparts of the GadgetBlock together.
  526. X
  527. X    Buffer  is  a pointer to a unitialized GadgetBlock, which contains
  528. Xthe  necessary  Gadget, Border, border pairs and IntuitText structures
  529. Xneeded to render a boolean gadget with a border and some text.
  530. X
  531. X    String  is  a  pointer  to  the text that should appear inside the
  532. Xgadget.   The  gadget  is  automatically  sized  to  match the strings
  533. Xlength.
  534. X
  535. X    X  and  Y are the gadgets initial position, they are simply copied
  536. Xinto LeftEdge and TopEdge in the gadget structure.
  537. X
  538. XRETURNS
  539. XSEE
  540. XBUGS
  541. XEXAMPLE
  542. X
  543. X
  544. X;--------------------------------------------------------------------
  545. X
  546. XNAME
  547. X            MakeString
  548. X
  549. XSYNOPSIS
  550. XMakeString(Buffer,StringBuff,UndoBuff,MaxWidthBits,MaxNumChars, X, Y)
  551. X             A0      A1          A2        D0          D1      D2  D3
  552. X
  553. Xstruct Buffer   *StringBlock;
  554. Xchar            *StringBuff;
  555. Xchar            *UndoBuff;
  556. Xlong            MaxWidthBits, MaxNumChars, X, Y;
  557. X
  558. XDESCRIPTION
  559. X
  560. X    As  with  all  of  the  MakeGadget  functions, this one prepares a
  561. Xbuffer  to  be used as a string gadget, that may be used re-entrantly.
  562. XThe  buffer need not be cleared first.  This means that you may create
  563. Xa temporary gadget on the stack.
  564. X
  565. X    The  StringBuff  is  where the body of text inside the gadget will
  566. Xreside.
  567. X
  568. X    When   the   gadget  is  activated,  the  text  in  StringBuff  is
  569. Xautomatically copied (by intuition) into UndoBuff.  This allows you to
  570. Xtype  Amiga-Q  and get the old string back.  This field may be null if
  571. Xyou wish to have no undo.
  572. X
  573. X    MaxWidthBits is the width of the frame around the gadget.
  574. X
  575. X    MaxNumChars  is  the maximum number of characters that you will be
  576. Xable  to  type  into the gadget, including the terminating zero on the
  577. Xstring.  MAKE SURE that this number is no greater than your StringBuff
  578. Xsize, or else you're going to be typing over memory that isn't yours.
  579. X
  580. X    X,Y  are the position of the upper left hand corner of the gadget.
  581. XThe border is actually 2 pixels above and to the left of this corner.
  582. X
  583. XRETURNS
  584. X    Nothing
  585. XSEE
  586. X
  587. X    MakeGadget,MakeProp,MakeScrollbar,LinkGadget,LinkProp,LinkString
  588. X
  589. X
  590. X;--------------------------------------------------------------------
  591. X
  592. XNAME
  593. X            MakeProp
  594. XSYNOPSIS
  595. X
  596. XMakeProp(Buffer,Width,Height,Flags)
  597. X         A0       D0   D1    D2
  598. X
  599. Xstruct  Buffer  *PropBlock;
  600. Xlong            Width, Height, Flags;
  601. X
  602. XDESCRIPTION
  603. X
  604. X    This  routine  prepares an un-initialized buffer for use as a prop
  605. Xgadget.
  606. X
  607. X    Buffer,  on  return,  will  contain  the  gadget,  along  with the
  608. Xnecessary PropInfo and Image structures, all linked together.
  609. X
  610. X    Width is the with of the container, in pixels.
  611. X    Height is the height of the container in pixels.
  612. X
  613. X    The  Flags  parameter  is  where you decide if you want FREEHORIZ,
  614. XFREEVERT, or both.  It is simply copied into the gadget flags field.
  615. X
  616. X
  617. XRETURNS
  618. X
  619. X    Nothing
  620. X
  621. X
  622. X;--------------------------------------------------------------------
  623. X
  624. XNAME
  625. X            DrawBox
  626. XSYNOPSIS
  627. X
  628. XDrawBox(rp,MinX,MinY,MaxX,MaxY)
  629. X        A1  D0   D1   D2   D3
  630. X
  631. Xstruct  RastPort        *rp;
  632. Xlong    MinX,MinY,MaxX,MaxY;
  633. X
  634. X
  635. XDESCRIPTION
  636. X
  637. X        This  routine  allows you to draw a simple box in one command.
  638. XIt  draws  the  box  in APen color, in the current draw mode, with the
  639. Xcurrent line pattern.
  640. X
  641. X        (MinX,MinY)  are  the  upper  left  corner  of  the  box,  and
  642. X(MaxX,MaxY) are the lower right.
  643. X
  644. X        The pen is left at the upper left corner (MinX,MinY).
  645. X
  646. X;--------------------------------------------------------------------
  647. X
  648. XNAME
  649. X            MakeButton
  650. XSYNOPSIS
  651. X
  652. XMakeButton(Buffer,Image,Image2,Width,Height,Depth)
  653. X             A0     A1    A2     D0    D1    D2
  654. X
  655. X
  656. Xstruct  TwoImageGadget  *Buffer;
  657. Xchar    *Image;     /* Pointer to the actual bitplane data */
  658. Xchar    *Image2;    /* Pointer to the second image. */
  659. Xlong    Width,Height,Depth;
  660. X
  661. X
  662. X
  663. X
  664. XDESCRIPTION
  665. X
  666. X    The  purpose  of  this  routine  is one similar to MakeGadget, but
  667. Xinstead of using text for the button, it uses a graphic.  You supply a
  668. Xbitmap, and MakeButton will use it in it's rendering.
  669. X
  670. X    You  may  have  either  one  or two images, the routine handles it
  671. Xroutinely.   If you supply one image, then this sets GADGHCOMP, and if
  672. Xyou  have two images, it sets GADGHIMAGE.  RELVERIFY is always set, so
  673. Xas  long  as  you  the  user  is  pressing  that gadget, the alternate
  674. Xhighlight is shown.
  675. X
  676. X    Buffer has room for two images.
  677. X
  678. X    Image  is  a pointer to the actual image data, in CHIP memory, for
  679. Xthis gadget.
  680. X    Image2 is a pointer to the alternate image data.
  681. X
  682. X    Width and Height make up the size of your image.
  683. X
  684. X    Depth is how many bitplanes of data you've supplied.
  685. X
  686. XBUGS
  687. X    It's  not  really  a bug, but if your images aren't the same size,
  688. Xthen one won't erase the other when it is drawn, so you may be showing
  689. Xan image with traces of the other one left there.
  690. X
  691. X;--------------------------------------------------------------------
  692. X
  693. XNAME
  694. X            MakeScrollBar
  695. XSYNOPSIS
  696. X
  697. XMakeScrollBar(Buffer,Flags,Size,X,Y)
  698. X                A0    D0    D1 D2 D3
  699. X
  700. Xstruct ScrollBlock *Buffer;
  701. Xlong    Flags,Size,X,Y;
  702. X
  703. X
  704. XDESCRIPTION
  705. X
  706. X    This is a special routine that creates a scrollbar (which consists
  707. Xof  a prop gadget and two arrows) and you handle it like it's a single
  708. Xgadget.   You  may  have  either a horizontal scrollbar, or a vertical
  709. Xscrollbar.   These scrollbars are very much like the ones in workbench
  710. Xwindow  borders.   These  use slightly different images on the arrows,
  711. Xhowever.
  712. X
  713. X    The  way  you  determine  how  this set up and oriented is by flag
  714. Xcombinations.   If  you wished to put a scrollbar in the bottom border
  715. Xof a window, then you would pass (in flags):
  716. X
  717. X        Flags = (HORIZSLIDER | GRELBOTTOM | GRELWIDTH)
  718. X
  719. X    If you wished it in the right border:
  720. X
  721. X        Flags = (VERTSLIDER | GRELRIGHT | GRELHEIGHT)
  722. X
  723. X    The  idea is to allow you to manipulate the scrollbar as though it
  724. Xwere  a  single  gadget, not three.  If you pass confusing flags (like
  725. XGRELBOTTOM|GRELHEIGHT) then it is undefined what will happen.
  726. X
  727. X    If all you want is a simple scrollbar that doesn't size, then just
  728. Xset VERTSLIDER or HORIZSLIDER.
  729. X
  730. XSEE
  731. X
  732. X
  733. X;--------------------------------------------------------------------
  734. X
  735. XNAME
  736. X            PurgeFiles
  737. XSYNOPSIS
  738. X    PurgeFiles(&FileRequesterStructure)
  739. X                        A0
  740. XDESCRIPTION
  741. X    Clear  up  all  memory  and  file  locks  allocated  by  the  file
  742. Xrequester.   This  routine must be called before your program exits if
  743. Xyou  use  the  file requester with either FRQEXTSELECTM bit set or the
  744. XFRQCACHINGM bit set.  The first bit is if you want the user to be able
  745. Xto select multiple files.  The file requester has to allocate a linked
  746. Xlist  of  file  names which this function will purge.  The FRQCACHINGM
  747. Xbit  is set if you want the file requester to remember the contents of
  748. Xa directory between calls.
  749. X
  750. X    This  routine can be called any time you want the buffers and file
  751. Xlocks purge.
  752. X
  753. XRETURNS
  754. X    This routine does not return anything.
  755. X
  756. XSEE
  757. X    FileRequest
  758. XBUGS
  759. X    None known.
  760. XEXAMPLE
  761. X
  762. Xmain()
  763. X    {
  764. X    FileRequest(&FileRequesterStructure);
  765. X
  766. X    .
  767. X    .
  768. X    .
  769. X
  770. X    PurgeFiles(&FileRequesterStructure);
  771. X    }
  772. X
  773. X
  774. X
  775. X;--------------------------------------------------------------------
  776. X
  777. XNAME
  778. X            GetFontHeightAndWidth
  779. XSYNOPSIS
  780. X
  781. XDESCRIPTION
  782. X
  783. X        This allows you quick access to the font attributes set by the
  784. Xuser  in preferences.  The font width is returned in D0 and the height
  785. Xis returned in D1.
  786. X
  787. XRETURNS
  788. XSEE
  789. XBUGS
  790. XEXAMPLE
  791. X
  792. X
  793. X
  794. X;--------------------------------------------------------------------
  795. X
  796. XNAME
  797. X            LinkGadget
  798. XSYNOPSIS
  799. X
  800. XLinkGadget(Buffer,String,nw, X, Y)
  801. X             A0     A1   A3 D0 D1
  802. X
  803. Xstruct  GadgetBlock *Buffer;
  804. Xchar    *String;
  805. Xstruct  NewWindow *nw;
  806. Xlong    X,Y;
  807. X
  808. XDESCRIPTION
  809. X
  810. X    This  is  actually  a superset of the previous command MakeGadget.
  811. XWhat  this  does  is automatically link the gadget into your NewWindow
  812. Xstructure's gadget list.
  813. X
  814. X        No registers are disturbed.
  815. X
  816. XSEE
  817. X    MakeGadget
  818. XBUGS
  819. X    n/a
  820. X
  821. X
  822. X
  823. X;--------------------------------------------------------------------
  824. X
  825. XNAME
  826. X            LinkStringGadget
  827. XSYNOPSIS
  828. XLinkStringGadget(Buffer,StringBuf,UndoBuf,nw, WidthBits,NumChars, X, Y)
  829. X                   A0     A1        A2    A3     D0       D1     D2 D3
  830. X
  831. Xstruct  StringBlock *Buffer;
  832. Xchar    *StringBuf;
  833. Xchar    *UndoBuf;
  834. Xstruct  NewWindow *nw;
  835. Xlong    WidthBits,NumChars,X,Y;
  836. X
  837. XDESCRIPTION
  838. X
  839. X    This  is  number 2 in the LinkGadget routines.  This one obviously
  840. Xlinks  the  string  gadget  to the window's gadget list.  In fact, the
  841. Xonly  difference  between  this  and  the  MakeString  routine  is the
  842. Xaddition of the NewWindow pointer.
  843. X
  844. XSEE
  845. X    MakeStringGadget
  846. X
  847. X
  848. X;--------------------------------------------------------------------
  849. X
  850. XNAME
  851. X            LinkPropGadget
  852. XSYNOPSIS
  853. X
  854. XLinkPropGadget(Buffer,nw, Width, Height, Flags, LeftEdge, TopEdge)
  855. X                 A0   A3    D0     D1     D2       D3       D4
  856. X
  857. Xstruct  PropBlock   *Buffer;
  858. Xstruct  NewWindow   *nw
  859. Xlong    Width,Height,Flags,LeftEdge,TopEdge;
  860. X
  861. XDESCRIPTION
  862. X
  863. X    Here  we  have a superset for MakeProp.  It works exactly the same
  864. Xas  MakeProp,  except  that  it attaches the gadget to the head of the
  865. Xlist in the window.
  866. X
  867. XSEE
  868. X    MakeProp
  869. X
  870. X
  871. X;--------------------------------------------------------------------
  872. X
  873. XFileRequester
  874. X
  875. XNAME
  876. X    FileRequester  - bring up a file/font requester.
  877. X
  878. XSYNOPSIS
  879. X    success = FileRequester(&FileRequesterStructure)
  880. X      D0                              A0
  881. X
  882. XFUNCTION
  883. X    Bring  up  a  fully  intuitionized file/font requester (actually a
  884. Xwindow) and let the user select a file/font.
  885. X
  886. XINPUTS
  887. X    &FileRequesterStructure  -  pointer  to  an  initialized  (can  be
  888. Xinitialized mostly to zeroes) file requester structure.
  889. X
  890. XRESULT
  891. X    Returns  TRUE  or FALSE to say whether the user selected a file or
  892. Xnot.   The  file name(s) or font selected are then found by looking at
  893. Xthe file requester structure whose address was passed.
  894. X
  895. X    For  ideas  on  customizing the file requester for your particular
  896. Xsystem  (thus  overriding the defaults used by programmers who use the
  897. Xfile requester) see the customizefile.asm file.
  898. X
  899. XBUGS
  900. X    Problem  with  an  Intuition bug that messes up the current active
  901. Xwindow  if  a  window  closes  when one of its string gadgets is still
  902. Xactive.   This bug show up if you run the file requester straight from
  903. Xa CLI window and then exit it with Amiga-L.
  904. X    I have heard that it resets some window flags when run on a custom
  905. Xscreen,  but I believe this is a feature of Intuition, not of the file
  906. Xrequester.
  907. X
  908. XSEE ALSO
  909. X    PurgeFiles
  910. X
  911. X
  912. X    The  file  requester  in  the  requester  library  allows to put a
  913. Xpowerful  and  easy  to  use  file requester into your programs with a
  914. Xminimum of work and at a very small expense in program size.  The file
  915. Xrequester  was  designed  to be as easy as possible to call, while not
  916. Xsacrificing power.
  917. X
  918. X    To  get  the  file  requester to come up all you need to do (after
  919. Xopening  the  requester  library of course) is to allocate space for a
  920. XFileRequester  structure  and  then  call  the file requester with the
  921. Xaddress  of  this structure, with all fields initialized to zero, like
  922. Xthis:
  923. X
  924. Xstruct FileRequester MyFileReqStruct;
  925. X
  926. Xsuccess = FileRequester(&MyFileReqStruct);
  927. X
  928. X    The function will return either one or zero for success or failure
  929. Xrespectively.
  930. X
  931. X    You can specify what screen the file requester should appear on in
  932. Xone  of  two  ways.  If you want it to appear on a custom screen, then
  933. Xthe  best  way  is  to  set  the  pr_WindowPtr  field  in your process
  934. Xstructure  to  point at one of the windows on your screen (this should
  935. Xbe  done anyway, so that DOS requesters appear on your custom screen).
  936. XThis  field  is looked at by all functions in the requester library so
  937. Xthis  way  is the simplest method.  The other way, which overrides the
  938. Xpr_WindowPtr  field  is to initialize the frq_Window field to point at
  939. Xone of your windows.  If this field is non-zero, it is used instead of
  940. Xthe pr_WindowPtr field of your process structure.  Important note:  It
  941. Xis  VERY  important  that you reset the pr_WindowPtr field back to its
  942. Xoriginal  value  before  your  program  exits.  If you don't, the next
  943. Xprogram run may try to open a requester window on a now closed screen.
  944. X
  945. X    The  file  requester  was  carefully  designed so that it could be
  946. Xcalled  without  having  to  initialize  very  many  fields.   This is
  947. Xdemonstrated  by  seeing  that  it  is  possible  to  call  it without
  948. Xinitializing any fields.  There are a few fields that are necessary to
  949. Xactually  get  any  use  out  of  it,  but  very  view.  Those few are
  950. Xdocumented in the following paragraph.
  951. X
  952. X    Although  you can bring the file requester up without initializing
  953. Xany  fields there are a couple of fields that you will definitely want
  954. Xto  initialize.   The  file  requester isn't much use unless you get a
  955. Xfile  name back out of it, and for this you need to initialize the Dir
  956. Xand  File  fields.   These two fields should point to character arrays
  957. Xthat  are,  respectively,  DSIZE+1  and FCHARS+1 bytes long.  When the
  958. Xfile  requester  is first run the file requester looks in these arrays
  959. Xfor  the  default  directory  and file names and if the user selects a
  960. Xfile  name  the  directory  and  file  name are copied back into these
  961. Xarrays.  You will probably want to initialize the Title field with the
  962. Xmessage  that you want to have appear at the top of the file requester
  963. Xwindow.
  964. X
  965. X    If  you initialize the PathName field (it should point an array of
  966. Xat least DSIZE+FCHARS+2 characters) then when the user selects a file,
  967. Xthe complete path name will be put into this array.
  968. X
  969. X    The Window field is used to specify what window the file requester
  970. Xis associated with.  This is used to get the file requester to show up
  971. Xon  a  custom  screen.   Generally  this  field should be unnecessary.
  972. XThere  is a variable provided in a process structure which is used for
  973. Xthis purpose.  Any program that opens a custom screen and uses any DOS
  974. Xfunctions  should set the pr_Window pointer in their process structure
  975. Xto  a  pointer  to their window so that DOS requesters will show up on
  976. Xtheir  custom  screen.   If  you do this, then the file requester will
  977. Xalso  show  up  on  your custom screen.  If you are not using a custom
  978. Xscreen  then you don't need to set the pr_Window pointer or the Window
  979. Xfield  in  the  file  requester  structure.   Note:  If you do set the
  980. Xpr_Window  structure in the process structure, be sure to return it to
  981. Xits old value before your program exits.
  982. X
  983. X    If  the  extended  select  bit  is set in the Flags field then the
  984. XMaxExtendedSelect  fields  specifies  the maximum number of files that
  985. Xthe user can select.  This is ignored if the extended bit isn't set in
  986. Xthe Flags field.
  987. X
  988. X    numlines and numcolumns specify the maximum size that the file box
  989. Xwill  be in characters.  If the system is low on memory, or the screen
  990. Xis  too  small,  these will be shrunk as necessary.  devcolumns is the
  991. Xnumber of columns of characters wide that the device box will be.
  992. X
  993. X    The  Flags field can currently contain seven different flags.  The
  994. Xfirst  flag,  FRQSHOWINFOM,  specifies  whether  or not '*.info' files
  995. X(files  containing information for icons) should be filtered out.  The
  996. Xdefault is for them to be filtered.
  997. X
  998. X    The  FRQEXTSELECTM  flags  specifies  whether  extended  select is
  999. Xwanted.   If  you  set this flag then you should probably also set the
  1000. XMaxExtendedSelect  field.   If  you  don't  then the maximum number of
  1001. Xfiles  the  user  will be able to select will be 65536, which is a bit
  1002. Xhigh  for  most  purposes.  Note:  If you use this bit then you _must_
  1003. Xcall  PurgeFiles()  with  the  address of your FileRequester structure
  1004. Xafter  the  last time you call the file requester, in order to free up
  1005. Xany  memory  used  in  the  extended select structures.  When the user
  1006. Xselects  multiple files, a linked list of the file names selected (not
  1007. Xincluding the directory name) will appear in the ExtendedSelect field.
  1008. XThe  list  is a linked list of ESStructures.  The directory name which
  1009. Xshould  be  prepended  to  all of these names will appear in the array
  1010. Xpointed to by the Dir field.
  1011. X
  1012. X    The  FRQCACHINGM  flag  specifies  whether  or not directories are
  1013. Xcached  from  one  call  to  the next.  This is a very handy features,
  1014. Xespecially  for those who lack hard drives.  However, if this features
  1015. Xis  used, you _must_ call the PurgeFiles() routine with the address of
  1016. Xyour  FileRequester  structure  after  the last time you call the file
  1017. Xrequester, in order to free up any memory used in caching.
  1018. X
  1019. X    As  well  as being a file requester, this routine can be used as a
  1020. Xfont requester too.  Just set the FRQGETFONTSM flags to turn it into a
  1021. Xfont  requester.   You  should  also  put the name 'fonts:' in the Dir
  1022. Xarray.   The file/font requester will return a one or zero for success
  1023. Xor  failure as usual, the font name will be returned in the File array
  1024. Xand  the  font  size  and  style will be returned in the FontYSize and
  1025. XFontStyle  fields.   Note  that  the font requester allows the user to
  1026. Xchange  the  directory  where  the  fonts are read from.  Although you
  1027. Xshould  put  'fonts:' there, you should allow for the possibility that
  1028. Xthe  user  might  change  the  directory.  They might, perhaps, have a
  1029. Xseparate  disk  full  of  fonts.   The simplest way to deal with fonts
  1030. Xcoming  from  different  directories,  is  to  set  the PathName field
  1031. Xinstead of the Dir field.  You can then use the string in the PathName
  1032. Xfield  (which  will  contain  the directory and font name) as the font
  1033. Xname.   If  you  don't  do this, then you have to concatenate the font
  1034. Xname  and  the  directory  name  yourself.   If  you  use the PathName
  1035. Xvariable  then  it  is quite reasonable to leave the File field blank,
  1036. Xsince  all  the information you need can be obtained from the PathName
  1037. Xstring.
  1038. X
  1039. X    The  FRQINFOGADGETM flag specifies whether or not a hide/show info
  1040. Xgadget should appear on the file requester.  This lets the user toggle
  1041. Xthe  state  of  the  FRQSHOWINFOM flag to decide whether or not to let
  1042. X'*.info'  files  show  up.  This is not recommended for most programs,
  1043. Xsince  most  users  have  no  reason  to  look at '*.info' files.  The
  1044. Xdefault is to _not_ have this gadget show up.
  1045. X
  1046. X    The FRQHIDEWILDSM flag specifies whether or not to have 'show' and
  1047. X'hide'  string  gadgets.   These gadgets let the user use wildcards to
  1048. Xspecify  which  files  should  show  up.  All files are first compared
  1049. Xagainst  the 'show' gadget.  If they fail the comparison, they are not
  1050. Xdisplayed.  Then they are compared against the 'hide' gadget.  If they
  1051. Xmatch  here then they are not displayed.  If the gadgets are empty, no
  1052. Xcomparisons  are done.  Important note:  Even if these gadgets are not
  1053. Xdisplayed,  the comparisons are still done on the data which is in the
  1054. XHide  and  Show  fields of the file requester structure.  The standard
  1055. XAmigaDOS wildcards (including '#', '?', '|' and '*') are supported.
  1056. X
  1057. X    Normally  the  file  requester  appears  centered  under the mouse
  1058. Xpointer.   If  you would like to specify its opening position you must
  1059. Xset   the   ABSOLUTEXYM   flag  and  then  put  the  x,y  position  in
  1060. XWindowLeftEdge and WindowTopEdge.
  1061. X
  1062. X    If you feel that the file requester's cached directories (selected
  1063. Xby  FRQCACHINGM)  should  be  purged  whenever  the directory has been
  1064. Xchanged,  then  set  FRQCACHEPURGEM  field and the file requester will
  1065. Xcheck the dates whenever it is opened.
  1066. X
  1067. X    If you feel that the file requester should never cache directories
  1068. Xunless  it  manages  to  read  in the entire directory before the user
  1069. Xsends  it  away,  then  set  the FRQNOHALFCACHEM flag.  This flag will
  1070. Xcause  the file requester to automatically flush any incompletely read
  1071. Xdirectories when it exits.
  1072. X
  1073. X    If  you  would  like your directories to appear in 'natural' order
  1074. Xinstead of alphabetically sorted, set the FRQNOSORTM flag.
  1075. X
  1076. X    If you would like the file requester to appear without a drag bar
  1077. Xor depth arrangement gadgets, set the FRQNODRAGM flag.
  1078. X
  1079. X    If  you  are using the file requester to select a filename to save
  1080. Xto,  you  should set the FRQSAVINGM flag.  Similarly, if you are using
  1081. Xthe  file  requester to select a filename to load from, you should set
  1082. Xthe  FRQLOADINGM flag.  These flags are not currently used by the file
  1083. Xrequester,  but  they  may  be  used in the future.  They also make it
  1084. Xeasier  for  people who want to personalize the file requester to make
  1085. Xit behave differently for loading vs.  saving.
  1086. X
  1087. X
  1088. X    The  various  color  fields  let  you  specify  the colors of many
  1089. Xaspects of the file requester.  If they are left as zero then the file
  1090. Xrequester uses various non-zero certain default values for them.
  1091. X
  1092. X    The  WindowLeftEdge  and  WindowTopEdge  fields are covered in the
  1093. Xsection on the ABSOLUTEXYM flag.
  1094. X
  1095. X    The  FontYSize  and FontStyle fields are covered in the section on
  1096. Xthe FRQGETFONTSM flag.
  1097. X
  1098. X    The  ExtendedSelect  field  is  covered  in  the  section  on  the
  1099. XFRQEXTSELECTM flag.
  1100. X
  1101. X    The  Hide  and  Show  fields  are  covered  in  the section on the
  1102. XFRQHIDEWILDSM flag.
  1103. X
  1104. XSet this bit if you are selecting a file to save to.
  1105. XSet this bit if you are selecting a file(s) to load from.
  1106. XThese two bits (save and load) aren't currently used for
  1107. Xanything, but they may be in the future, so you should
  1108. Xremember to set them.  Also, these bits make it easier if
  1109. Xsomebody wants to customize the file requester for their
  1110. Xmachine.  They can make it behave differently for loading
  1111. Xvs saving.
  1112. X
  1113. X    The  four  BufferPos  and  DispPos  variables  are  copies  of the
  1114. Xequivalent  variables  from  the four string gadgets.  This is so that
  1115. Xwhen  the  file  requester goes away and then is brought up again, the
  1116. Xcursor in the string gadgets will appear in the same places as before.
  1117. XThese fields should not need to be touched by the programmer.
  1118. X
  1119. X    The  rest  of the fields are private.  Don't go touching them.  We
  1120. Xguarantee  to  move them around and change their meaning, just to make
  1121. Xsure  that  nobody tries to use them.  They are largely concerned with
  1122. Xkeeping  track  of  memory  used in directory caching.  This memory is
  1123. Xfreed  with  the  PurgeFiles() routine.  That's all you should need to
  1124. Xknow.
  1125. X
  1126. X
  1127. X
  1128. X
  1129. X
  1130. X;--------------------------------------------------------------------
  1131. X
  1132. XRealTimeScroll
  1133. X
  1134. XNAME
  1135. X    RealTimeScroll  -  do the calculations necessary for a responsive,
  1136. Xpixel resolution, real time scroll routine.
  1137. X
  1138. XSYNOPSIS
  1139. X    RealTimeScroll(&ScrollStruct);
  1140. X                         A0
  1141. X
  1142. XFUNCTION
  1143. X    Make  the  implementation  of  real time scrolling area easier and
  1144. Xmake the real time scrolling area more responsive to the user by doing
  1145. Xpixel resolution scrolling and by checking the current position of the
  1146. Xscroll  bar  in mid scroll.  This routine calculates how far to scroll
  1147. Xeach  time  and calculates which lines of text, graphics etc.  need to
  1148. Xbe redrawn to fill in the empty area.
  1149. X
  1150. XINPUTS
  1151. X    &ScrollStruct - pointer to an initialized scroll structure.
  1152. X
  1153. XRESULT
  1154. X    This routine returns no result code.
  1155. X
  1156. XBUGS
  1157. X    None known
  1158. X
  1159. XSEE ALSO
  1160. X    n/a
  1161. X
  1162. X
  1163. X    It is relatively easy to implement a real time scrolling area, but
  1164. Xthe most obvious implementations suffer from a lack of responsiveness.
  1165. XTypically  the  routines  look  at  where the scroll bar is, calculate
  1166. Xwhere  to  scroll  to,  scroll  there  in  several  jumps  to make the
  1167. Xscrolling  look smooth, and the examine the scroll bar again to see if
  1168. Xit  has  moved.  This means that there are periods, perhaps annoyingly
  1169. Xlong,  where  the  program may be scrolling in one direction while the
  1170. Xscroll  bar is being dragged in another.  The answer is to examine the
  1171. Xscroll  bar  to  find out the desired location, scroll partway towards
  1172. Xthe  destination and then recheck the scroll bar's location.  This can
  1173. Xgreatly  increase  the  responsiveness,  since the program is checking
  1174. Xafter  every  ScrollRaster()  call,  instead of after a dozen or more.
  1175. XHowever,  the  calculations,  especially  of  which  lines  need to be
  1176. Xrefreshed  and  where, get somewhat more complicated.  This routine is
  1177. Xdesigned  to  simplify this situation by taking care of as many of the
  1178. Xmessy details as possible.
  1179. X
  1180. X    First   you   must   initialize   the   scroll   structure.    The
  1181. XTopEntryNumber, NumEntries and NumLines fields describe where the data
  1182. Xis  currently.   NumEntries  is  the number of lines of data in total,
  1183. XNumLines  is  the number of lines that are visible, and TopEntryNumber
  1184. Xis the line number of the first line visible (it therefore ranges from
  1185. Xzero to NumEntries - 1).
  1186. X
  1187. X    LineSpacing  is  the  number of pixels high that each line of data
  1188. Xis.   For  text  this  will  typically be eight or nine (for eighty or
  1189. Xsixty  column  topaz).   This  can  be  set  to  one  if  your data is
  1190. Xcontinuous (as in the case of some graphics).
  1191. X
  1192. X    PropGadget  is a pointer to the prop gadget which is being used to
  1193. Xcontrol this scroll area.
  1194. X
  1195. X    RedrawAll  is  a  pointer  to  a  function that you must supply to
  1196. Xredraw the entire visible window.  This routine is called whenever the
  1197. Xuser  gets  so far ahead of the scroll routine that scrolling to where
  1198. Xthe  users  wants  to  be  would  take  to  long.  Before calling this
  1199. Xroutine,  the  ScrollStruct that was passed to this routine is updated
  1200. Xwith  the  desired TopEntryNumber so that your routine will know which
  1201. Xdata to redraw.
  1202. X
  1203. X    ReadMore is an optional routine that will usually not be used.  It
  1204. Xis  used  if more data is being added while the scrolling is going on.
  1205. XThis  is  used,  for  instance,  by  the  FileRequest in the requester
  1206. Xlibrary, to continue attempting to read the directoy while the user is
  1207. Xscrolling.   Leave  this set to zero if you don't need it.  It is only
  1208. Xcalled  when no scrolling is being done, but the user has not released
  1209. Xthe scroll bar.
  1210. X
  1211. X    ScrollAndDraw  is the most important routine.  This routine, which
  1212. Xyou  must  supply,  is called whenever the data must be scrolled.  The
  1213. Xactual  scrolling  and  redrawing of the data is done by this routine,
  1214. Xbut because the scroll amount, the lines to be drawn and the number of
  1215. Xlines  to  be  drawn are passed to this routine, the routine is fairly
  1216. Xsimple.  Four parameters are passed to this routine:
  1217. X
  1218. XScrollAndDraw(firstlinenum, firstliney, scrollamount, numlines);
  1219. X
  1220. X    All  four parameters are passed as longs, both on the stack and in
  1221. XD0-D3,  so  that  the  routine  can  easily  be written in either C or
  1222. Xassembler.
  1223. X
  1224. X    When the ScrollAndDraw, ReadMore or RedrawAll routines are called,
  1225. XA4,  A5  and  A6  all  contain  the  same  values  they contained when
  1226. XRealTimeScroll  was  called.   This allows programs written in C using
  1227. Xthe  small  data  model  to be able to access their data properly from
  1228. Xthese  routines without any special work.  All other registers (except
  1229. Xthose that are used to pass parameters in) could contain anything.
  1230. X
  1231. X
  1232. X
  1233. X
  1234. X;--------------------------------------------------------------------
  1235. X
  1236. X
  1237. X
  1238. XTextRequest
  1239. X
  1240. XNAME
  1241. X    TextRequest  - bring up a text requester with one to three gadgets
  1242. Xand get a response.
  1243. X
  1244. XSYNOPSIS
  1245. X    result = TextRequest(&TRStructure);
  1246. X      D0                      A0
  1247. X
  1248. XFUNCTION
  1249. X    Bring  up  a requester (actually a window) containing a message to
  1250. Xthe  user  and  give  him  a  choice  of  from  one to three different
  1251. Xresponses.   The  window  automatically  sizes  to  fit  the  text and
  1252. Xprintf() style formatting can be used by TextRequest() to generate the
  1253. Xmessage to the user.
  1254. X
  1255. XINPUTS
  1256. X    &TRStructure - pointer to an initialized text requester structure.
  1257. X
  1258. XRESULT
  1259. X    Returns  either  zero,  one  or two, depending on which gadget the
  1260. Xuser  clicks  on.   All  of  the  gadgets  are  optional,  so that the
  1261. Xrequester  can  be  used  to  bring up requesters that give the user a
  1262. Xmessage,  without demanding an answer, by having only a single gadget.
  1263. XThe  gadget  in  the  lower  right  hand  corner (the negative gadget)
  1264. Xreturns a zero, the gadget in the lower left hand corner (the positive
  1265. Xgadget)  returns a one and the gadget in the middle returns a two.  If
  1266. Xnone  of these three gadgets are requested, a close gadget is attached
  1267. Xto the window and it returns a zero.
  1268. X
  1269. XBUGS
  1270. X    If  any  line  of  the  text  to  be printed is too long, then the
  1271. Xrequester  will  attempt  to open up an impossibly large window, which
  1272. Xwill fail and the requester will return a zero.
  1273. X    The  buffer used for formatting the text is 5000 bytes long, so no
  1274. Xmessages can be longer than this.
  1275. X
  1276. XSEE ALSO
  1277. X    SimpleRequest
  1278. X    TwoGadRequest
  1279. X
  1280. X
  1281. X    The  purpose  of  this  routine  is  to  make  it as easy to print
  1282. Xformatted  messages  in  intuitionized window with gadgets as it is to
  1283. Xprint  them  on the CLI screen.  For maximum ease of use, at a loss of
  1284. Xflexibility,  please see the functions SimpleRequest and TwoGadRequest
  1285. Xwhich  are  simply  glue  code functions to make calling TextRequest a
  1286. Xtrivial matter.
  1287. X
  1288. X    If  you want the text requester to appear on a custom screen, then
  1289. Xyou must set the pr_WindowPtr field in your process structure to point
  1290. Xat  one  of the windows on your screen (this should be done anyway, so
  1291. Xthat  DOS  requesters  appear  on  your custom screen).  This field is
  1292. Xlooked at by all functions in the requester library so this way is the
  1293. Xsimplest method.  Important note:  It is VERY important that you reset
  1294. Xthe  pr_WindowPtr field back to its original value before your program
  1295. Xexits.  If you don't, the next program run may try to open a requester
  1296. Xwindow on a now closed screen.
  1297. X
  1298. X    The  structure  whose  address  is  passed to this routine must be
  1299. Xinitialized first.
  1300. X
  1301. X    The  Text field is initialized with the body of the text you would
  1302. Xlike  displayed.  This text can contain both printf() style formatting
  1303. Xand  end  of  line characters ('\n' in C, ascii 10 in assembler).  The
  1304. Xprintf()  style formatting, is expanded out into the final text string
  1305. Xusing  the  parameter  list which is pointed to by the Controls field.
  1306. XLine  feeds  are  used, as usual, to specify a new line, thus allowing
  1307. Xvery  long  and  complex  messages  to  be  displayed.   The  are some
  1308. Xlimitations  on  the  types  of  printf() formatting that can be used.
  1309. XSince the RawDoFmt() function of the ROM is used to do the formatting,
  1310. Xonly   functions   supported   by   it  can  be  used.   For  complete
  1311. Xdocumentation,  see  the documentation of the RawDoFmt() command.  The
  1312. Xmain  things  to be aware of is that floating point numbers can not be
  1313. Xprinted,  and,  if  you  are using a compiler that uses thirty-two bit
  1314. Xints  then  we  will  have to specify '%ld' to print an int, since the
  1315. XRawDoFmt command assumes an int size of sixteen bits.
  1316. X
  1317. X    The Controls field points to a list of parameters, one for each of
  1318. Xthe  '%'  parameters in the Text field.  Normally these will be pushed
  1319. Xon  to the stack and the stack pointer copied into the Controls field.
  1320. XThe first parameter used (the first one to occur in the string) should
  1321. Xbe  at  the beginning of the list, that is, at the lowest address, the
  1322. Xone pointed at by the Controls parameter.
  1323. X
  1324. X    The Window field can be used to specify what screen you would like
  1325. Xthe requester to appear on.  This field is usually not necessary since
  1326. Xthe same information can be conveyed in the pr_WindowPtr field of your
  1327. Xprocess  structure.   However  this  field  was  left  in  so that the
  1328. XTextRequest  function  could  be  called  from  a  task (which lacks a
  1329. Xprocess  structure and therefore a pr_WindowPtr field).  If this field
  1330. Xis  non-zero or if the calling program is a task then this field takes
  1331. Xprecedence over the pr_WindowPtr field.
  1332. X
  1333. X    MiddleText,  PositiveText  and NegativeText are the pieces of text
  1334. Xused  for  the  three gadgets.  These three gadgets, when present, are
  1335. Xplaced   in  the  middle,  the  left  and  the  right  of  the  window
  1336. Xrespectively.   All  three  gadgets are placed along the bottom of the
  1337. Xwindow.   All of the gadgets are optional.  If a gadget is not wanted,
  1338. Xthe  text  pointer  should be set to zero.  The values returned if the
  1339. Xuser  clicks  on these gadgets are two, one or zero, respectively.  If
  1340. Xnone  of  the gadgets are present (if all of the text fields are zero)
  1341. Xthen  a  standard  CLOSEWINDOW gadget is attached to the window.  This
  1342. Xgadget returns a zero.
  1343. X
  1344. X    The  requester  attempt  to  appear so that the negative gadget is
  1345. Xunderneath  the  mouse pointer.  If the negative gadget is not present
  1346. Xit will attempt to appear so that a different gadget is underneath the
  1347. Xmouse  pointer.   This is to make it as convenient as possible for the
  1348. Xuser  to  respond  to,  and  especially  to respond negatively to, the
  1349. Xrequester.
  1350. X
  1351. X    In  addition  to  responding  to  the  requester  with  the mouse,
  1352. Xkeyboard  shortcuts are available.  The user can type ESC, 'N', 'Q' or
  1353. X'B'  as  a  shortcut to clicking on the negative gadget.  The user can
  1354. Xtype  'Y'  or 'V' as a shortcut to clicking on the positive gadget and
  1355. Xcan type 'M' as a shortcut to clicking on the middle gadget.
  1356. X
  1357. X    The  Title  field  of  the structure should either point to a null
  1358. Xterminated  string  to  be  used in the windows title bar or should be
  1359. Xnull.
  1360. X
  1361. X    The  KeyMask  field  is  used  to  regulate  the  use  of keyboard
  1362. Xshortcuts.  The qualifier field of all keyboard messages is ANDed with
  1363. Xthis  field,  and  the  keypress  is  ignored  if  the result is zero.
  1364. XTherefore,  to enable all keypresses to be used as keyboard shortcuts,
  1365. Xinitialize  this  field to $FFFF.  To turn off the keyboard shortcuts,
  1366. Xinitialize  this  field to 0.  To force the user to hold down the left
  1367. Xor right amiga key, initialize this field to AMIGAKEYS.
  1368. X
  1369. X    The  textcolor,  detailcolor  and  blockcolor  fields  can be left
  1370. Xunitialized (ie; set to zero) if you wish, in which case the requester
  1371. Xwill  use  the  default values of one, zero and one respectively.  The
  1372. Xtextcolor  field  is used for the color of the actual text message and
  1373. Xthe detail and block color fields are simple copied into the fields of
  1374. Xthe same name in the new window structure.
  1375. X
  1376. X;--------------------------------------------------------------------
  1377. X
  1378. X
  1379. XSimpleRequest
  1380. X
  1381. XNAME
  1382. X    SimpleRequest - bring up a text requester and wait for the user to
  1383. Xacknowledge it.
  1384. X
  1385. XSYNPOSIS
  1386. X    SimpleRequest(string, parameterlist, , ,)
  1387. X                    A0        A1
  1388. X
  1389. XFUNCTION
  1390. X    Bring  up  a requester (actually a window) containing a message to
  1391. Xthe  user  and  wait  for  the  user  to  acknowledge  it.  The window
  1392. Xautomatically  sizes to fit the text and printf() style formatting can
  1393. Xbe used by TextRequest() to generate the message to the user.
  1394. X
  1395. XINPUTS
  1396. X    string  -  a  null  terminated  string,  containing printf() style
  1397. Xformatting commands if desired.
  1398. X    parameterlist - the parameters corresponding to the printf() style
  1399. Xformatting  commands  in  the string.  In C these are listed after the
  1400. Xcontrol  string,  exactly as with printf().  In assembler, the address
  1401. Xof the list of parameters is put in A1.
  1402. X
  1403. XRESULT
  1404. X    No result code is returned.
  1405. X
  1406. XBUGS
  1407. X    See TextRequest
  1408. X
  1409. XSEE ALSO
  1410. X    TextRequest
  1411. X    TwoGadRequest
  1412. X
  1413. X
  1414. X    This  function was designed to make it as easy to give messages to
  1415. Xthe  user  and await acknowledgment in an intuition style requester as
  1416. Xit  is  using  printf() and getc().  Simply replace almost any call to
  1417. Xprintf()  with a call to SimpleRequest and a requester will appear and
  1418. Xnot  disappear until the user acknowledges it (either with a keystroke
  1419. Xor with the mouse).
  1420. X
  1421. X    Example:
  1422. X        SimpleRequest("There  have  %d  changes  made  to this file.",
  1423. X                        numchanges);
  1424. X
  1425. X    Please  see  the  TextRequest  documentation for further important
  1426. Xdetails.   This  routine  is simply a few lines of assembler glue code
  1427. Xfor  the TextRequest routine.  The TextRequest routine is a little bit
  1428. Xmore   complicated   to   use,  but  it  allows  correspondingly  more
  1429. Xflexibility.   It  is  fairly  simple to modify the glue code to allow
  1430. Xstill more high level entry points to the TextRequest routine.
  1431. X
  1432. X
  1433. X    This  is  a  complete  program that makes use of the SimpleRequest
  1434. Xfunction  from  assembler,  and  demonstrates a few of the features of
  1435. XFormat (which is used by SimpleRequest).
  1436. X
  1437. X;--------------------------------------------------------------------
  1438. X;-----CUT HERE---------------CUT HERE--------------------------------
  1439. X;--------------------------------------------------------------------
  1440. X
  1441. X    INCLUDE "libraries/reqbase.i"
  1442. X
  1443. X    public  SimpleRequest
  1444. X    public  _ReqBase,_main
  1445. X
  1446. X;--------------------------------------------------------
  1447. X; This file should be linked with reqglue.o, for the SimpleRequest
  1448. X;function.
  1449. X;--------------------------------------------------------
  1450. X
  1451. XSYS MACRO
  1452. X    XREF    _LVO\1
  1453. X    JSR _LVO\1(A6)
  1454. X    ENDM
  1455. X
  1456. X;--------------------------------------------------------
  1457. X
  1458. X
  1459. X_main
  1460. X    OpenReq
  1461. Xmystart
  1462. X
  1463. X    MOVE.L  A6,A5
  1464. X    MOVE.L  A6,_ReqBase
  1465. X
  1466. X
  1467. X    PEA     string
  1468. X    MOVE.L  #$C0FFEE,-(SP)
  1469. X    MOVE.W  #$1CE,-(SP)
  1470. X    MOVE.W  #'B',-(SP)
  1471. X    MOVE.L  #-12345,-(SP)
  1472. X    MOVE.L  SP,A1
  1473. X    LEA     Text,A0
  1474. X    JSR     SimpleRequest
  1475. X
  1476. X    LEA     16(SP),SP
  1477. X
  1478. X    MOVE.L  A5,A1
  1479. X    MOVE.L  4,A6
  1480. X    SYS     CloseLibrary
  1481. X
  1482. X    MOVEQ   #0,D0
  1483. X    RTS
  1484. Xstring
  1485. X    DC.B    "This is a string.",0
  1486. XText
  1487. X    DC.B    "A long (signed) decimal is: %ld,",10
  1488. X    DC.B    "a character is: %c,",10
  1489. X    DC.B    "a 16 bit hex val might be: %x, ",10
  1490. X    DC.B    "a register-style format 32 bit hex: $%08lx,",10
  1491. X    DC.B    "and a string might read: `%s'.",0
  1492. X
  1493. X    dseg
  1494. X
  1495. X_ReqBase    DC.L    0   ;The SimpleRequest function in the glue code
  1496. X                        ;needs this variable.
  1497. X
  1498. X    END
  1499. X
  1500. X;--------------------------------------------------------------------
  1501. X;-----CUT HERE---------------CUT HERE--------------------------------
  1502. X;--------------------------------------------------------------------
  1503. X
  1504. X
  1505. X
  1506. X
  1507. X;--------------------------------------------------------------------
  1508. X
  1509. X
  1510. X
  1511. XTwoGadRequest
  1512. X
  1513. XNAME
  1514. X    TwoGadRequest - bring up a text requester and wait for the user to
  1515. Xacknowledge it.
  1516. X
  1517. XSYNPOSIS
  1518. X    result = TwoGadRequest(string, parameterlist, , ,)
  1519. X                             A0        A1
  1520. X
  1521. XFUNCTION
  1522. X    Bring  up  a requester (actually a window) containing a message to
  1523. Xthe user and wait for the user to click on either the OK or the CANCEL
  1524. Xgadget.   The  window automatically sizes to fit the text and printf()
  1525. Xstyle  formatting can be used by TextRequest() to generate the message
  1526. Xto the user.
  1527. X
  1528. XINPUTS
  1529. X    string  -  a  null  terminated  string,  containing printf() style
  1530. Xformatting commands if desired.
  1531. X    parameterlist - the parameters corresponding to the printf() style
  1532. Xformatting  commands  in  the string.  In C these are listed after the
  1533. Xcontrol  string,  exactly as with printf().  In assembler, the address
  1534. Xof the list of parameters is put in A1.
  1535. X
  1536. XRESULT
  1537. X    Either  one  or  zero  is  returned, depending on whether the user
  1538. Xselected, respectively, the OK or the CANCEL gadget.
  1539. X
  1540. XBUGS
  1541. X    See TextRequest
  1542. X
  1543. XSEE ALSO
  1544. X    TextRequest
  1545. X    SimpleRequest
  1546. X
  1547. X
  1548. X    This  function was designed to make it as easy to give messages to
  1549. Xthe  user  and get a response in an intuition style requester as it is
  1550. Xusing printf() and getc().  Simply replace almost any call to printf()
  1551. Xwith  a  call  to  SimpleRequest  and  a requester will appear and not
  1552. Xdisappear  until  the  user responds to it (either with a keystroke or
  1553. Xwith the mouse).
  1554. X
  1555. X    Example:
  1556. X        if (TwoGadRequest("There have %d changes made to this file.\n"
  1557. X                          "O.K. to continue?",
  1558. X                          numchanges))
  1559. X            exit(10);
  1560. X
  1561. X    Please  see  the  TextRequest  documentation for further important
  1562. Xdetails.   This  routine  is simply a few lines of assembler glue code
  1563. Xfor  the TextRequest routine.  The TextRequest routine is a little bit
  1564. Xmore   complicated   to   use,  but  it  allows  correspondingly  more
  1565. Xflexibility.   It  is  fairly  simple to modify the glue code to allow
  1566. Xstill more high level entry points to the TextRequest routine.
  1567. X
  1568. X
  1569. X
  1570. X-------------------------------------------------------------------
  1571. XNAME
  1572. X    GetString
  1573. X
  1574. XBOOL = GetString(buffer, title, window, visiblechars, maxchars)
  1575. XD0                 A0      A1     A2        D0          D1
  1576. X
  1577. XDESCRIPTION
  1578. X    This  routine allows you to bring up a nice intuition style string
  1579. Xrequester  in  its  own window and get a single line of input from the
  1580. Xuser in just a one line function call.
  1581. X
  1582. X    buffer  points  to  the  a buffer containing the string which will
  1583. Xappear  when  the string gadget first appears and it is also where the
  1584. Xresult will be put, if this routine returns TRUE.
  1585. X    Title  is  a pointer to a null terminated string that will be used
  1586. Xfor the window title.
  1587. X    Window  can  be  used  to  specify  what screen you would like the
  1588. Xrequester  to  appear on.  You simply put a window pointer in it (or a
  1589. Xzero if you want the requester to appear on the workbench screen).  If
  1590. Xyou have already set your pr_WindowPtr then you can simply pass a zero
  1591. Xfor the window pointer and the pr_WindowPtr value will be used.
  1592. X    visiblechars  specifies  how  many  characters  should actually be
  1593. Xvisible at one time.
  1594. X    maxchars   specifies   how  long  the  buffer  is,  including  the
  1595. Xterminating zero.
  1596. X
  1597. XRETURNS
  1598. X    This  routine returns true or false, depending on whether the user
  1599. Xclicked  on  the  cancel  gadget  (FALSE)  or clicked on the OK gadget
  1600. X(TRUE)  or clicked on the close window gadget (FALSE) or hit return in
  1601. Xthe string gadget (TRUE).
  1602. X
  1603. XBUGS
  1604. X    None known.
  1605. X
  1606. X
  1607. X
  1608. X-------------------------------------------------------------------
  1609. XNAME
  1610. X    GetLong
  1611. X
  1612. XBOOL = GetLong(&GetLongStruct)
  1613. XD0                   A0
  1614. X
  1615. XDESCRIPTION
  1616. X    This  routine allows you to bring up a nice intuition style string
  1617. Xrequester  in  its  own  window and get a single signed thirty-two bit
  1618. Xnumber  from the user in just a one line function call (although a few
  1619. Xfields in the structure must be initialized first).
  1620. X
  1621. X    The  GetLongStruct  contains  fields  for  letting you specify the
  1622. Xtitle  bar  message,  the  default  value  that  should  appear in the
  1623. Xrequester  and  the maximum and minimum values that the routine should
  1624. Xallow  to  be  entered.   If  the  routine  returns  TRUE  (indicating
  1625. Xsuccessful  entry  of  a  number)  then  the result is returned in the
  1626. Xresult field of the structure.
  1627. X    The window field can be used to specify what screen you would like
  1628. Xthe requester to appear on.  You simply put a window pointer in it (or
  1629. Xa  zero  if you want the requester to appear on the workbench screen).
  1630. XIf  you  have  already set your pr_WindowPtr then you can simply leave
  1631. Xthe window field zeor and the pr_WindowPtr value will be used.
  1632. X
  1633. XRETURNS
  1634. X    This  routine  returns  TRUE  or  FALSE  (1 or 0) in D0 to specify
  1635. Xwhether  or  not  the  user  successfully  entered  a number.  If this
  1636. Xroutine  returns TRUE then you can find the result in the result field
  1637. Xof the GetLongStruct whose address you passed to GetLong.
  1638. X
  1639. X
  1640. X
  1641. X-------------------------------------------------------------------
  1642. XRawKeyToAscii
  1643. X
  1644. XSYNOPSIS
  1645. X
  1646. X key = RawKeyToAscii(Code,Qualifier,IAddress)
  1647. X D0                   D0     D1        A0
  1648. X
  1649. X UWORD  Code,Qualifier;
  1650. X APTR   IAddress;
  1651. X
  1652. XFUNCTION
  1653. X
  1654. X    Have you ever wanted to have both RAW and COOKED keys?  You can do
  1655. Xit by checking the keys for whatever raw keys you want, and then using
  1656. Xthe  console.device's RawKeyConvert routine, except that it's a hassle
  1657. Xto start mucking about with the device.
  1658. X
  1659. X    Well, here you go!  A nice, clean way of converting from a raw key
  1660. Xto  a  cooked  key,  in a single call!  All you have to do is pass the
  1661. Xcode  and  qualifier  from  your  intuimessage, and the address of the
  1662. Xmessage  itself, and you will get back the ASCII value of the key that
  1663. Xwas  hit.  This does, in fact, use the console.device's RawKeyConvert,
  1664. Xso that if you have a different keymap set, it will be used.
  1665. X
  1666. XEXAMPLE
  1667. X
  1668. X
  1669. Xstruct IntuiMessage *im;
  1670. X
  1671. X    key = RawKeyToAscii(im->Code,im->Qualifier,im->IAddress);
  1672. X
  1673. END_OF_FILE
  1674. if test 60498 -ne `wc -c <'req.doc'`; then
  1675.     echo shar: \"'req.doc'\" unpacked with wrong size!
  1676. fi
  1677. # end of 'req.doc'
  1678. fi
  1679. echo shar: End of archive 3 \(of 3\).
  1680. cp /dev/null ark3isdone
  1681. MISSING=""
  1682. for I in 1 2 3 ; do
  1683.     if test ! -f ark${I}isdone ; then
  1684.     MISSING="${MISSING} ${I}"
  1685.     fi
  1686. done
  1687. if test "${MISSING}" = "" ; then
  1688.     echo You have unpacked all 3 archives.
  1689.     rm -f ark[1-9]isdone
  1690. else
  1691.     echo You still need to unpack the following archives:
  1692.     echo "        " ${MISSING}
  1693. fi
  1694. ##  End of shell archive.
  1695. exit 0
  1696. -- 
  1697. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  1698. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  1699. Post requests for sources, and general discussion to comp.sys.amiga.
  1700.